package com.heo.protocol.packet;

import org.apache.log4j.Logger;


public class PutCoinReq extends BasePacket
{
  private int BODY_LENGTH = 0;// 包体长0个字节
  private static final String PACKET_NAME = "[投币请求包]";

  private static Logger log = Logger.getLogger(PutCoinReq.class);

  /**
   * 通过网络传过来的流构建对象
   * 
   * @param totalLength
   * @param commandId
   * @param sequenceId
   * @param body
   * @throws Exception
   */
  public PutCoinReq(String logHeader, SocketPacket packet) throws Exception
  {
    super.copyPacket(logHeader, PACKET_NAME, packet);
    makeBody();
  }
  
  public PutCoinReq() throws Exception
  {
    super();
    super.commandId = DeviceCommand.PUT_COIN_REQ;
    super.sequenceId = 0x01;
    super.totalLength = HEAD_LENGTH + BODY_LENGTH;
  }
  
  @Override
  public int getTotalLength()
  {
    return super.HEAD_LENGTH + BODY_LENGTH;
  }

  @Override
  public byte[] getPacketBody()
  {
    return new byte[0];
  }

  @Override
  public void makeBody() throws Exception
  {
    if (packetBody.length != BODY_LENGTH)
    {
      log.error(super.logHeader + super.packetName + "数据包长度错误。包体长度应该为：" + BODY_LENGTH + "个字节。");
      throw new Exception(super.logHeader + super.packetName + "数据包长度错误。包体长度应该为：" + BODY_LENGTH + "个字节。");
    }
    log.debug(super.logHeader + super.packetName + "数据包解析成功。");
  }

  public static void main(String[] args)
  {

  }

}
